package com.graduate.cec.config;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.URLUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *解决跨域问题
 * @author Administrator
 */
@Slf4j
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //registry.addResourceHandler("/picture/**").addResourceLocations("file:/D:/IDEA2021/graduate/cec_management/picture/");
        //registry.addResourceHandler("/picture/**").addResourceLocations("file:/D:/IDEA2021/graduate/cec_management/picture/");
        registry.addResourceHandler("/picture/**").addResourceLocations("file:/D:/runtimeSoftware/IDEA/graduation/cec_management/picture/");
    }


    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowCredentials(true)
                .allowedHeaders("*")
                .allowedMethods("*")
                .maxAge(3600);
    }
}
